<template>
  <div>
    <p>父组件</p>
    <input type="text" v-model="num" />
    <!-- <p>{{ num }}</p> -->
    <button @click="parentTap">parent</button>
  </div>
</template>

<script>
import bus from "@/config/eventBus.js";
export default {
  name: "parent",
  props: {
    // num: {
    //   Number,
    //   default: 0
    // }
  },
  data() {
    return {
      num: 2
    };
  },
  methods: {
    parentTap() {
      bus.$emit("pushPMsg", this.num);
    }
  },
  mounted() {
    var that = this;
    bus.$on("pushMsg", function(num) {
      window.console.log(num);
      that.num += num;
    });
  }
};
</script>

<style scoped></style>
